<?php

/**
 * @Author: wuchenge
 * @Date: 2020-12-07 21:11:53
 * @email: ligui0506@sina.com
 * @descript:
 */

namespace App\Requests\rbac;

use App\Requests\FormRequest;

class AdminRequest extends FormRequest
{
    public function rules()
    {
        // 默认
        return [
            'account'   => 'required|alpha_dash',
            'nick_name' => 'required',
            'roles'     => 'required|array',
            'status'    => 'required|numeric',
            'password'  => 'nullable|confirmed',
        ];
    }

    public function messages()
    {
        return [
            'account.required'   => 100201,
            'account.alpha_dash' => 100202,
            'nick_name.required' => 100203,
            'roles.required'     => 100204,
            'roles.array'        => 100205,
            'status.required'    => 100206,
            'status.numeric'     => 100207,
            'password.confirmed' => 100208,
        ];
    }

    public $scene = [
        'admin.rbac.admin.modify' => ['account', 'nick_name', 'roles', 'status', 'passwd_confirmation', 'password'],
        'admin.rbac.admin.center' => ['nick_name', 'passwd_confirmation', 'password'],
    ];
}
